<?php
	session_start();
	include("../include/config.php");
	include("../include/functions.php");
	
		if(isset($_POST['password'])){
			$_POST['original_pwd']=$_POST['password'];
			$_POST['password']=md5($_POST['password']);
			$_POST['updated_date']=date("Y-m-d H:i:s");
						mysqli_query($db_connect, "UPDATE `cns_admin` SET `password`='$_POST[password]',`original_pwd`='$_POST[original_pwd]',			`updated_date`='$_POST[updated_date]' WHERE id='$_SESSION[adminid]' ");
			//db_update(DB_PREFIX.'admin',$_POST,array('id'=>$_SESSION['adminid']));
		}
		else{
			if(isset($_POST['global_id']) && $_POST['global_id']==''){
				$global_id=array_shift($_POST);
				$_POST['updated_date']=date("Y-m-d H:i:s");
				$_POST['created_date']=date("Y-m-d H:i:s");
				mysqli_query($db_connect, "INSERT INTO `cns_globalsettings`(`contactemail`, `fb_link`, `twitter_link`, 				`linked_link`, `youtube`, `created_date`, `updated_date`) 				VALUES ('$_POST[contactemail]','$_POST[fb_link]','$_POST[twitter_link]','$_POST[linked_link]',				'$_POST[youtube]','$_POST[created_date]','$_POST[updated_date]')");
				
			}else{
				$global_id=array_shift($_POST);
				$_POST['updated_date']=date("Y-m-d H:i:s");								$sel = mysqli_query($db_connect, "UPDATE `construction`.`cns_globalsettings` SET `contactemail` = '$_POST[contactemail]', 				`fb_link`='$_POST[fb_link]',`twitter_link`='$_POST[twitter_link]',`linked_link`='$_POST[linked_link]',				`youtube`='$_POST[youtube]',`updated_date`='$_POST[updated_date]' WHERE `cns_globalsettings`.`global_id` = '$global_id';");				//echo $sel; exit;
				//db_update(DB_PREFIX.'globalsettings',$_POST,array('global_id'=>$global_id));
			}
		}
			header('location:../admin.php?data=settings&msg=updated');
	
?>
